package com.me.libgdx_test;

import java.util.ArrayList;
import java.util.Arrays;;

public class AbstractClassCharacter {
	protected int attack;
	protected float perm_attack_bonus = 0;
	protected float attack_bonus = 0;
	protected float concrete_attack_bonus = 0;
	protected float totem_bonus = 0;
	protected float on_kill_bonus = 0;
	protected float on_step_bonus = 0;
	protected float dbl_hit_bonus = 0;
	protected float dodge_bonus = 0;
	protected float lower_bounds = .7f;
	protected float upper_bounds = 1.1f;
	protected int health_bonus = 0;
	protected int max_health;
	protected int current_health;
	protected int lives = 1;
	protected int level = 1;
	protected Point location = new Point();
	protected boolean spell_bonus = false;
	//The mods need to be in this abstract class as well
	//These are the mods that the character fights with. Usually permanent.
	//Ailments good in this context
	//protected ClassCharacterAilments attack_ailments;
	//protected ClassCharacterMods attack_mods;
	//These are the mods the character gets from fighting. Usually temporary
	//Ailments bad in this context
	//protected ClassCharacterAilments ailments = new ClassCharacterAilments();
	//protected ClassCharacterMods mods = new ClassCharacterMods();
	
	//These mods take effect when attacking
	protected ArrayList<ClassCharacterModDungeon> attack_mods;
	//These mods are contracted from being attack
	protected ArrayList<ClassCharacterModDungeon> contracted_mods;
	//These are mods that the player is immune to receiving from enemies
	protected ArrayList<ClassCharacterModDungeon> immune_mods;
	
	/*public void set_ailments(int ail_mburn, int ail_poison, int ail_forget, int ail_blind, int ail_weakness, int ail_static){
		attack_ailments = new ClassCharacterAilments(ail_mburn, ail_poison, ail_forget, ail_blind, ail_weakness, ail_static);
	}
	public void set_mods(int mod_MRnorm, int mod_MRplus, int mod_PRnorm, 
			int mod_PRplus, int mod_magicalAttack, int mod_undead, int mod_coward, 
			int mod_banish,int mod_fStrike, int mod_blood){
		attack_mods = new ClassCharacterMods(mod_MRnorm, mod_MRplus, mod_PRnorm, mod_PRplus, mod_magicalAttack, mod_undead,
				mod_coward,mod_banish,mod_fStrike, mod_blood);
	}*/
	public void cure_all(){
		for(ClassCharacterModDungeon mod:contracted_mods){
			if(mod.get_info_mods().get_ailment()){
				mod.set_has_mod(false);
			}
		}
	}
	public void cure_heal(){
		for(ClassCharacterModDungeon mod:contracted_mods){
			if(mod.get_info_mods().Name == "Poison" || mod.get_info_mods().Name == "Weakness" || mod.get_info_mods().Name == "Blind"){
				mod.set_has_mod(false);
			}
		}
	}
	//The list of mods and the classes hte have them
	/*public void set_starting_mods(ClassCharacterModDungeon[] mod_types, ClassPlayerSituationMods class_mods){
		attack_mods = new ArrayList<ClassCharacterModDungeon>();
		contracted_mods = new ArrayList<ClassCharacterModDungeon>();
		immune_mods = new ArrayList<ClassCharacterModDungeon>();
		for(ClassCharacterModDungeon mod:mod_types){
			attack_mods.add(new ClassCharacterModDungeon(mod.get_info_mods(),class_mods.attack.contains(mod.get_info_mods().Name)));
			contracted_mods.add(new ClassCharacterModDungeon(mod.get_info_mods(),class_mods.contract.contains(mod.get_info_mods().Name)));
			immune_mods.add(new ClassCharacterModDungeon(mod.get_info_mods(),class_mods.immune.contains(mod.get_info_mods().Name)));
		}
	}*/
	public void set_attack_mod(String name, boolean has_mod){
		for(ClassCharacterModDungeon mod:attack_mods){
			if(mod.get_info_mods().Name == name){
				mod.set_has_mod(has_mod);
			}
		}
	}
	public boolean get_attack_mod(String name){
		for(ClassCharacterModDungeon mod:attack_mods){
			if(mod.get_info_mods().Name == name){
				return mod.get_has_mod();
			}
		}
		return false;
	}
	public void set_immune_mod(String name, boolean has_mod){
		for(ClassCharacterModDungeon mod:immune_mods){
			if(mod.get_info_mods().Name == name){
				mod.set_has_mod(has_mod);
			}
		}
	}
	public boolean get_immune_mod(String name){
		for(ClassCharacterModDungeon mod:immune_mods){
			if(mod.get_info_mods().Name == name){
				return mod.get_has_mod();
			}
		}
		return false;
	}
	public void set_contracted_mod(String name, boolean has_mod){
		for(ClassCharacterModDungeon mod:contracted_mods){
			if(mod.get_info_mods().Name == name){
				mod.set_has_mod(has_mod);
			}
		}
	}
	public boolean get_contracted_mod(String name){
		for(ClassCharacterModDungeon mod:contracted_mods){
			if(mod.get_info_mods().Name == name){
				return mod.get_has_mod();
			}
		}
		return false;
	}
	public boolean has_status_benefit(){
		for(ClassCharacterModDungeon mod:contracted_mods){
			if(mod.get_has_mod() && !mod.get_info_mods().get_ailment()){
				return true;
			}
		}
		return false;
	}
	public float health_left(){
		System.out.println("Ratio: " + (float)current_health/(float)get_max_health());
		return (float)current_health/(float)get_max_health()<0?0:(float)current_health/(float)get_max_health();
	}
	public void set_location(Point location){
		this.location = location;
	}
	public Point get_location(){
		return location;
	}
	public ArrayList<ClassCharacterModDungeon> get_attack_mods(){
		return attack_mods;
	}
	public ArrayList<ClassCharacterModDungeon> get_contracted_mods(){
		return contracted_mods;
	}
	//public ClassCharacterAilments get_attack_ailments(){
	//	return attack_ailments;
	//}
	//public ClassCharacterAilments get_ailments(){
	//	return ailments;
	//}
	public String get_health_ratio(){
		return String.valueOf(current_health) + "/" + String.valueOf(get_max_health());
	}
	public void reset_attack_bonus(){
		dbl_hit_bonus = 0;
		dodge_bonus = 0;
		attack_bonus = 0;
		concrete_attack_bonus = 0;
		spell_bonus = false;
	}
	public void add_temp_spell_bonus(float bonus){
		if(!spell_bonus){
			spell_bonus = true;
			add_attack_bonus(bonus);
		}
	}
	public void add_attack_bonus(float bonus){
		attack_bonus += bonus;
	}
	public float get_attack_bonus(){
		return perm_attack_bonus + attack_bonus + concrete_attack_bonus + on_kill_bonus + on_step_bonus + totem_bonus;
	}
	public int get_max_health(){
		return max_health + health_bonus;
	}
	public void check_health(){	
		if(current_health > get_max_health()){
			current_health = get_max_health();
		}
	}
	public void refresh_shroud(int shroud_amount){
		if(!this.get_contracted_mod("Poison")){
			current_health += shroud_amount * level;
		}
		check_health();
	}
}
